package model;

import java.util.StringTokenizer;

public class UpfileModel {
	public String getpath(String path) {
        StringTokenizer tocken = new StringTokenizer(path, "\\");
        StringBuilder stringBuilder = new StringBuilder();
        String temp = ".metadata";
        for(int i = 0 ; i <tocken.countTokens();i++){
        	String easy = tocken.nextToken();
        	if(easy.compareTo(temp)==0){
        		break;
        	}
        	stringBuilder.append(easy);
    		stringBuilder.append("\\");
        	
        }
        stringBuilder.append("phantrang\\WebContent\\images\\");
        String pathReal = new String(stringBuilder);
        return pathReal;
    }
    public String getfilePath(String path){
    	StringTokenizer tocken = new StringTokenizer(path, "\\");
        StringBuilder stringBuilder = new StringBuilder();
        String temp = "images";
        int count = tocken.countTokens();
        int i=0;
        for(i = 0 ; i <count;i++){
        	String easy = tocken.nextToken();
        	if(easy.compareTo(temp)==0){
        		stringBuilder.append(easy);
        		stringBuilder.append("/");
        		stringBuilder.append(tocken.nextToken());
        		break;
        	}
        }
        String pathReal = new String(stringBuilder);
        return pathReal;  
    }
    public String get_report_path(String path) {
        StringTokenizer tocken = new StringTokenizer(path, "\\");
        StringBuilder stringBuilder = new StringBuilder();
        String temp = ".metadata";
        for(int i = 0 ; i <tocken.countTokens();i++){
        	String easy = tocken.nextToken();
        	if(easy.compareTo(temp)==0){
        		break;
        	}
        	stringBuilder.append(easy);
    		stringBuilder.append("\\");
        	
        }
        stringBuilder.append("phantrang\\reports\\");
        String pathReal = new String(stringBuilder);
        return pathReal;
    }
}
